package AppConfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
	Sms struct {
		Account  string
		Password string
	}
	Real struct {
		SecretId  string
		SecretKey string
	}
}

var Config AppConfig

func Init() {
	viper.SetConfigFile("../AppConfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		return
	}

	err = viper.Unmarshal(&Config)
	if err != nil {
		return
	}

	fmt.Println("配置文件读取成功")
}
